const { DataTypes, INTEGER } = require('sequelize')
const sequelize = require('../config/database')

const OrderModel = sequelize.define('Order', {
  order_id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    allowNull: false,
    autoIncrement: true
  },
  user_id: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  place_id: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  order_type: {
    type: DataTypes.ENUM('scenery', 'hotel', 'restaurant'),
    allowNull: false
  },
  place_name: {
    type: DataTypes.STRING,
    allowNull: false
  },
  product_type: {
    type: DataTypes.STRING,
    allowNull: false
  },
  price: {
    type: DataTypes.DECIMAL(10, 2),
    allowNull: false
  },
  quantity: {
    type: INTEGER,
    allowNull: false
  },
  description: {
    type: DataTypes.TEXT,
    allowNull: false
  },
  total_amount: {
    type: DataTypes.DECIMAL(10, 2),
    allowNull: false
  },
  travel_start_date: {
    type: DataTypes.DATE,
    allowNull: false
  },
  travel_end_date: {
    type: DataTypes.DATE,
    allowNull: false
  },
  people: {
    type: DataTypes.JSON,
    allowNull: false
  },
  status: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 0
  },
  createdAt: {
    type: DataTypes.TIME
  }
}, {
  freezeTableName: true,
  tableName: 'order',
  timestamps: false
})

module.exports = OrderModel